// generated 2005/10/14 21:24:48 CST by xihels@163.com


#if defined __GNUC__ && __GNUC__ < 3
#error This program will crash if compiled with g++ 2.x
// see the dynamic_cast bug in the gtkmm FAQ
#endif //
#include "config.h"
#include <gtkmmconfig.h>
#if GTKMM_MAJOR_VERSION==2 && GTKMM_MINOR_VERSION>2
#define GMM_GTKMM_22_24(a,b) b
#else //gtkmm 2.2
#define GMM_GTKMM_22_24(a,b) a
#endif //
#include "FindBuddyWindow.h"
#include <gdk/gdkkeysyms.h>
#include <gtkmm/accelgroup.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/box.h>
#include <gtkmm/alignment.h>
#include <gtkmm/label.h>
#include <gtkmm/frame.h>
#include <gtkmm/table.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/button.h>

#include "MainWindow.h"
#include "QQSession.h"

#include "FriendList.h"
#include "pixmaps.h"

#define _FIND_WHAT		0
#define _HOW_FIND		1
#define _PRECISION_FIND		2
#define _ADVANCED_FIND		3
#define _FIND_CLUSTER		4
#define _FIND_FRIEND_RESULT	5
#define _FIND_CLUSTER_RESULT	6
#define _FIND_ONLINE		1

FindBuddyWindow::FindBuddyWindow(QQSession* _session) :
    Gtk::Window(Gtk::WINDOW_TOPLEVEL),
    session(_session),
    currentFind(_FIND_WHAT)
{  

    Gtk::Window *findBuddyWindow = this;
    gmm_data = new GlademmData(get_accel_group());

    friendResultList = Gtk::ListStore::create(friendResultColumns);
    clusterResultList = Gtk::ListStore::create(clusterResultColumns);

    Gtk::RadioButton::Group _RadioBGroup_radiobuttonFindBuddy;
    
    radiobuttonFindBuddy = 
	Gtk::manage(new class Gtk::RadioButton(
		    _RadioBGroup_radiobuttonFindBuddy,
		    "查找好友(_F)", true));
    
    radiobuttonFindCluster = 
	Gtk::manage(new class Gtk::RadioButton(
		    _RadioBGroup_radiobuttonFindBuddy,
		    "查找群(_C)", true));

    Gtk::VBox *vboxFindWhat =
       	Gtk::manage(new class Gtk::VBox(false, 5));
    
    Gtk::Alignment *alignmentFindWhat =
       	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 0.7));
    alignmentFindWhat->set_padding(0, 0, 12, 0);
    
    Gtk::Label *labelFindWhat =
       	Gtk::manage(new class Gtk::Label("<b><big>查找什么</big></b>"));
    
    Gtk::Frame *frameFindWhat =
       	Gtk::manage(new class Gtk::Frame());

    
    Gtk::RadioButton::Group _RadioBGroup_radiobuttonFindOnline;
    radiobuttonFindOnline = 
	Gtk::manage(new class Gtk::RadioButton(
		    _RadioBGroup_radiobuttonFindOnline, 
		    "在线用户(_O)", true));
    
    radiobuttonPreciseFind =
       	Gtk::manage(new class Gtk::RadioButton(
		    _RadioBGroup_radiobuttonFindOnline,
		    "精确查找(_R)", true));
    
    radiobuttonAdvancedFind = 
	Gtk::manage(new class Gtk::RadioButton(
		    _RadioBGroup_radiobuttonFindOnline,
		    "高级查找(_A)", true));

    Gtk::VBox *vboxHowFind = 
	Gtk::manage(new class Gtk::VBox(false, 5));
    
    Gtk::Alignment *alignmentHowFind =
       	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 0.7));
    alignmentHowFind->set_padding(0, 0, 12, 0);
    
    Gtk::Label *labelHowFind = 
	Gtk::manage(new class Gtk::Label("<b><big>如何查找</big></b>"));
    
    Gtk::Frame *frameHowFind = 
	Gtk::manage(new class Gtk::Frame());
    
    entryUid = Gtk::manage(new class Gtk::Entry());
    entryNickname = Gtk::manage(new class Gtk::Entry());
    entryEmail = Gtk::manage(new class Gtk::Entry());

    Gtk::Label *labelUid = 
	Gtk::manage(new class Gtk::Label("_QQ号", true));
    
    Gtk::Label *labelNickname =
       	Gtk::manage(new class Gtk::Label("昵称(_I)", true));
    
    Gtk::Label *labelEmail =
       	Gtk::manage(new class Gtk::Label("电子邮件(_E)", true));
    
    Gtk::Table *tablePreciseFind =
       	Gtk::manage(new class Gtk::Table(2, 2, false));

    
    
    Gtk::Alignment *alignmentPreciseFind = 
	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 0.7));
    alignmentPreciseFind->set_padding(0, 0, 12, 12);
    
    Gtk::Label *labelPreciseFind =
       	Gtk::manage(new class Gtk::Label("<b><big>精确查找</big></b>"));
    
    Gtk::Frame *framePreciseFind = 
	Gtk::manage(new class Gtk::Frame());
    
    checkbuttonAdvancedFindOnline = 
	Gtk::manage(new class Gtk::CheckButton("在线用户(_O)", true));
    
    checkbuttonAdvancedFindVideo =
       	Gtk::manage(new class Gtk::CheckButton("有摄像头(_V)", true));

    Gtk::HBox *hboxAdvancedFind = 
	Gtk::manage(new class Gtk::HBox(false, 0));
    
    comboboxentryCity = Gtk::manage(new class Gtk::ComboBoxEntry());
    
    comboboxAge = Gtk::manage(new class Gtk::ComboBox());
    
    comboboxSex = Gtk::manage(new class Gtk::ComboBox());
    
    comboboxentryProvince = Gtk::manage(new class Gtk::ComboBoxEntry());
    
    labelProvince = Gtk::manage(new class Gtk::Label("省份(_P)", true));

    Gtk::Label *labelCity = 
	Gtk::manage(new class Gtk::Label("城市(_C)", true));
    
    Gtk::Label *labelAge = 
	Gtk::manage(new class Gtk::Label("年龄(_A)", true));
    
    Gtk::Label *labelSex =
       	Gtk::manage(new class Gtk::Label("性别(_S)", true));
    
    Gtk::Table *tableAdvancedFindBase = 
	Gtk::manage(new class Gtk::Table(2, 2, false));
    
    Gtk::Alignment *alignmentAdvancedFindBase = 
	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 0.8));
    alignmentAdvancedFindBase->set_padding(10, 60, 22, 60);
    
    Gtk::Label *labelAdvancedFindBase =
       	Gtk::manage(new class Gtk::Label("<b>基本条件</b>"));
    
    Gtk::Frame *frameAdvancedFindBase =
       	Gtk::manage(new class Gtk::Frame());
    
    Gtk::VBox *vboxAdvancedFind = 
	Gtk::manage(new class Gtk::VBox(false, 0));
    
    Gtk::Alignment *alignmentAdvancedFind = 
	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 0.7));
    alignmentAdvancedFind->set_padding(0, 0, 12, 0);
    
    Gtk::Label *labelAdvancedFind =
       	Gtk::manage(new class Gtk::Label("<b><big>高级查找</big></b>"));
    
    Gtk::Frame *frameAdvancedFind =
       	Gtk::manage(new class Gtk::Frame());

   //////////////// 
    
    Gtk::Label *labelClusterId = 
	Gtk::manage(new class Gtk::Label("群号(_N)", true));
    
    entryClusterId = Gtk::manage(new class Gtk::Entry());

    Gtk::HBox *hboxFindCluster = 
	Gtk::manage(new class Gtk::HBox(false, 0));
    
    Gtk::Alignment *alignmentFindCluster = 
	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 0.7));
    alignmentFindCluster->set_padding(0, 0, 12, 0);
    
    Gtk::Label *labelFindCluster =
       	Gtk::manage(new class Gtk::Label("<b><big>查找群</big></b>"));
    
    Gtk::Frame *frameFindCluster = 
	Gtk::manage(new class Gtk::Frame());

    
    treeviewClusterResult = Gtk::manage(new class Gtk::TreeView(clusterResultList));

    Gtk::ScrolledWindow *scrolledwindowClusterResult = 
	Gtk::manage(new class Gtk::ScrolledWindow());
    
    buttonDetailedClusterResult =
       	Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-info")));
    
    buttonAddClusterResult = 
	Gtk::manage(new class Gtk::Button("添加(_A)", true));
    
    Gtk::HBox *hboxClusterResult = 
	Gtk::manage(new class Gtk::HBox(false, 0));

    Gtk::VBox *vboxClusterResult = Gtk::manage(new class Gtk::VBox(false, 0));

    Gtk::Alignment *alignmentClusterResult = 
	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
    alignmentClusterResult->set_padding(12, 0, 12, 0);
    
    Gtk::Label* labelFindClusterResult = 
	Gtk::manage(new class Gtk::Label("<b><big>群查找结果</big></b>"));

    Gtk::Frame *frameClusterResult =
       	Gtk::manage(new class Gtk::Frame());

/////...............

    treeviewFriendResult = Gtk::manage(new class Gtk::TreeView(friendResultList));

    Gtk::ScrolledWindow *scrolledwindowFriendResult = 
	Gtk::manage(new class Gtk::ScrolledWindow());
    
    buttonDetailedFriendResult =
       	Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-info")));

    buttonPrevFriendResult = 
	Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-go-back")));

    buttonNextFriendResult = 
	Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-go-forward")));
    
    buttonAllFriendResult =
       	Gtk::manage(new class Gtk::Button("全部(_A)", true)); 
       
    buttonAddFriendResult = 
	Gtk::manage(new class Gtk::Button("添加(_A)", true));
    
    Gtk::HBox *hboxFriendResult = 
	Gtk::manage(new class Gtk::HBox(false, 0));

    Gtk::VBox *vboxFriendResult = Gtk::manage(new class Gtk::VBox(false, 0));
    
    Gtk::Alignment *alignmentFriendResult = 
	Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
    alignmentFriendResult->set_padding(12, 0, 12, 0);
    
    Gtk::Label* labelFindFriendResult = 
	Gtk::manage(new class Gtk::Label("<b><big>好友查找结果</big></b>"));

    Gtk::Frame *frameFriendResult =
       	Gtk::manage(new class Gtk::Frame());

    
    notebookFind =
       	Gtk::manage(new class Gtk::Notebook());
    
    buttonPrev =
       	Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-go-back")));
    
    buttonNext = 
	Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-go-forward")));
    
    buttonClose = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-close")));

    Gtk::HBox *hboxMain = 
	Gtk::manage(new class Gtk::HBox(false, 0));

    Gtk::VBox *vboxMain = 
	Gtk::manage(new class Gtk::VBox(false, 0));
    
    radiobuttonFindBuddy->set_flags(Gtk::CAN_FOCUS);
    radiobuttonFindBuddy->set_relief(Gtk::RELIEF_NORMAL);
    radiobuttonFindBuddy->set_mode(true);
    radiobuttonFindBuddy->set_active(false);
    
    radiobuttonFindCluster->set_flags(Gtk::CAN_FOCUS);
    radiobuttonFindCluster->set_relief(Gtk::RELIEF_NORMAL);
    radiobuttonFindCluster->set_mode(true);
    radiobuttonFindCluster->set_active(false);
    
    vboxFindWhat->pack_start(*radiobuttonFindBuddy, Gtk::PACK_SHRINK, 0);
    vboxFindWhat->pack_start(*radiobuttonFindCluster, Gtk::PACK_SHRINK, 0);
    
    alignmentFindWhat->add(*vboxFindWhat);

    labelFindWhat->set_use_markup(true);
    
    frameFindWhat->set_border_width(5);
    frameFindWhat->set_shadow_type(Gtk::SHADOW_NONE);
    frameFindWhat->set_label_align(0,0.5);
    frameFindWhat->add(*alignmentFindWhat);
    frameFindWhat->set_label_widget(*labelFindWhat);
    
    vboxHowFind->pack_start(*radiobuttonFindOnline, Gtk::PACK_SHRINK, 0);
    vboxHowFind->pack_start(*radiobuttonPreciseFind, Gtk::PACK_SHRINK, 0);
    vboxHowFind->pack_start(*radiobuttonAdvancedFind, Gtk::PACK_SHRINK, 0);
    
    alignmentHowFind->add(*vboxHowFind);
    
    labelHowFind->set_use_markup(true);
    
    frameHowFind->set_border_width(5);
    frameHowFind->set_shadow_type(Gtk::SHADOW_NONE);
    frameHowFind->set_label_align(0,0.5);
    frameHowFind->add(*alignmentHowFind);
    frameHowFind->set_label_widget(*labelHowFind);
    
    
    labelUid->set_alignment(0,0.5);
    labelUid->set_mnemonic_widget(*entryUid);
    
    labelNickname->set_alignment(0,0.5);
    labelNickname->set_mnemonic_widget(*entryNickname);
    
    labelEmail->set_alignment(0,0.5);
    labelEmail->set_mnemonic_widget(*entryEmail);
    
    tablePreciseFind->set_row_spacings(7);
    
    tablePreciseFind->attach(
	    *entryUid, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL,
	    Gtk::AttachOptions(), 0, 0);
    
    tablePreciseFind->attach(
	    *entryNickname, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, 
	    Gtk::AttachOptions(), 0, 0);
    
    tablePreciseFind->attach(
	    *entryEmail, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL,
	    Gtk::AttachOptions(), 0, 0);
    
    tablePreciseFind->attach(
	    *labelUid, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL,
	    Gtk::AttachOptions(), 0, 0);
    
    tablePreciseFind->attach(
	    *labelNickname, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, 
	    Gtk::AttachOptions(), 0, 0);
    
    tablePreciseFind->attach(
	    *labelEmail, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL,
	    Gtk::AttachOptions(), 0, 0);
    
    alignmentPreciseFind->add(*tablePreciseFind);
    
    labelPreciseFind->set_use_markup(true);
    
    framePreciseFind->set_border_width(5);
    framePreciseFind->set_shadow_type(Gtk::SHADOW_NONE);
    framePreciseFind->set_label_align(0,0.5);
    framePreciseFind->add(*alignmentPreciseFind);
    framePreciseFind->set_label_widget(*labelPreciseFind);
    
    
    hboxAdvancedFind->pack_start(*checkbuttonAdvancedFindOnline);
    hboxAdvancedFind->pack_start(*checkbuttonAdvancedFindVideo);
    
    labelProvince->set_alignment(0,0.5);
    labelProvince->set_mnemonic_widget(*comboboxentryProvince);
    
    labelCity->set_alignment(0,0.5);
    labelCity->set_mnemonic_widget(*comboboxentryCity);
    
    labelAge->set_alignment(0,0.5);
    labelAge->set_mnemonic_widget(*comboboxAge);
    
    labelSex->set_alignment(0,0.5);
    labelSex->set_mnemonic_widget(*comboboxSex);
    
    tableAdvancedFindBase->attach(
	    *comboboxentryCity, 1, 2, 1, 2, Gtk::FILL,
	    Gtk::FILL, 0, 0);
    
    tableAdvancedFindBase->attach(
	    *comboboxAge, 1, 2, 2, 3, Gtk::FILL,
	    Gtk::FILL, 0, 0);
    
    tableAdvancedFindBase->attach(
	    *comboboxSex, 1, 2, 3, 4, Gtk::FILL,
	    Gtk::FILL, 0, 0);
    
    tableAdvancedFindBase->attach(
	    *comboboxentryProvince, 1, 2, 0, 1, 
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    
    tableAdvancedFindBase->attach(
	    *labelProvince, 0, 1, 0, 1,
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    
    tableAdvancedFindBase->attach(
	    *labelCity, 0, 1, 1, 2,
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    tableAdvancedFindBase->attach(
	    *labelAge, 0, 1, 2, 3,
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    
    tableAdvancedFindBase->attach(
	    *labelSex, 0, 1, 3, 4,
	    Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
    
    alignmentAdvancedFindBase->add(*tableAdvancedFindBase);
    //alignmentAdvancedFindBase->set_border_width(10);
    
    labelAdvancedFindBase->set_use_markup(true);
    
    frameAdvancedFindBase->set_border_width(5);
    frameAdvancedFindBase->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    frameAdvancedFindBase->set_label_align(0,0.5);
    frameAdvancedFindBase->add(*alignmentAdvancedFindBase);
    frameAdvancedFindBase->set_label_widget(*labelAdvancedFindBase);
    
    vboxAdvancedFind->pack_start(*hboxAdvancedFind, Gtk::PACK_SHRINK, 0);
    vboxAdvancedFind->pack_start(*frameAdvancedFindBase);
    
    alignmentAdvancedFind->add(*vboxAdvancedFind);
    
    labelAdvancedFind->set_use_markup(true);

    frameAdvancedFind->set_border_width(5);
    frameAdvancedFind->set_shadow_type(Gtk::SHADOW_NONE);
    frameAdvancedFind->set_label_align(0,0.5);
    frameAdvancedFind->add(*alignmentAdvancedFind);
    frameAdvancedFind->set_label_widget(*labelAdvancedFind);
    
    labelClusterId->set_alignment(0.5,0.5);
    labelClusterId->set_mnemonic_widget(*entryClusterId);
    
    
    hboxFindCluster->pack_start(*labelClusterId);
    hboxFindCluster->pack_start(*entryClusterId);
    
    alignmentFindCluster->add(*hboxFindCluster);

    labelFindCluster->set_use_markup(true);
    
    frameFindCluster->set_border_width(5);
    frameFindCluster->set_shadow_type(Gtk::SHADOW_NONE);
    frameFindCluster->set_label_align(0,0.5);
    frameFindCluster->add(*alignmentFindCluster);
    frameFindCluster->set_label_widget(*labelFindCluster);

    treeviewClusterResult->set_rules_hint(false);
    treeviewClusterResult->set_reorderable(true);
    treeviewClusterResult->set_enable_search(true);
    treeviewClusterResult->set_headers_clickable(true);
    
    scrolledwindowClusterResult->set_border_width(10);
    scrolledwindowClusterResult->set_policy(Gtk::POLICY_AUTOMATIC,
	    Gtk::POLICY_AUTOMATIC);
    scrolledwindowClusterResult->set_shadow_type(Gtk::SHADOW_IN);
    scrolledwindowClusterResult->add(*treeviewClusterResult);

    buttonDetailedClusterResult->set_relief(Gtk::RELIEF_NONE);
    buttonAddClusterResult->set_relief(Gtk::RELIEF_NONE);
    
    hboxClusterResult->pack_start(*buttonDetailedClusterResult);
    hboxClusterResult->pack_start(*buttonAddClusterResult);

    vboxClusterResult->pack_start(*scrolledwindowClusterResult);
    vboxClusterResult->pack_start(*hboxClusterResult, Gtk::PACK_SHRINK, 0);

    alignmentClusterResult->add(*vboxClusterResult);
    
    labelFindClusterResult->set_use_markup(true);

    frameClusterResult->set_border_width(5);
    frameClusterResult->set_shadow_type(Gtk::SHADOW_NONE);
    frameClusterResult->set_label_align(0,0.5);
    frameClusterResult->add(*alignmentClusterResult);
    frameClusterResult->set_label_widget(*labelFindClusterResult);

   //................//

    treeviewFriendResult->set_rules_hint(false);
    treeviewFriendResult->set_reorderable(true);
    treeviewFriendResult->set_enable_search(true);
    treeviewFriendResult->set_headers_clickable(true);
    
    scrolledwindowFriendResult->set_border_width(10);
    scrolledwindowFriendResult->set_policy(Gtk::POLICY_AUTOMATIC,
	    Gtk::POLICY_AUTOMATIC);
    scrolledwindowFriendResult->set_shadow_type(Gtk::SHADOW_IN);
    scrolledwindowFriendResult->add(*treeviewFriendResult);

    buttonPrevFriendResult->set_relief(Gtk::RELIEF_NONE);
    buttonNextFriendResult->set_relief(Gtk::RELIEF_NONE);
    buttonDetailedFriendResult->set_relief(Gtk::RELIEF_NONE);
    buttonAllFriendResult->set_relief(Gtk::RELIEF_NONE);
    buttonAddFriendResult->set_relief(Gtk::RELIEF_NONE);
    
    hboxFriendResult->pack_start(*buttonPrevFriendResult);
    hboxFriendResult->pack_start(*buttonNextFriendResult);
    hboxFriendResult->pack_start(*buttonDetailedFriendResult);
    hboxFriendResult->pack_start(*buttonAllFriendResult);
    hboxFriendResult->pack_start(*buttonAddFriendResult);

    vboxFriendResult->pack_start(*scrolledwindowFriendResult);
    vboxFriendResult->pack_start(*hboxFriendResult, Gtk::PACK_SHRINK, 0);
    
    alignmentFriendResult->add(*vboxFriendResult);
    
    labelFindFriendResult->set_use_markup(true);

    frameFriendResult->set_border_width(5);
    frameFriendResult->set_shadow_type(Gtk::SHADOW_NONE);
    frameFriendResult->set_label_align(0,0.5);
    frameFriendResult->add(*alignmentFriendResult);
    frameFriendResult->set_label_widget(*labelFindFriendResult);
    
    notebookFind->set_show_tabs(false);

    notebookFind->append_page(*frameFindWhat);
    notebookFind->append_page(*frameHowFind);
    notebookFind->append_page(*framePreciseFind);
    notebookFind->append_page(*frameAdvancedFind);
    notebookFind->append_page(*frameFindCluster);
    notebookFind->append_page(*frameFriendResult);
    notebookFind->append_page(*frameClusterResult);

    buttonPrev->set_relief(Gtk::RELIEF_NORMAL);
    buttonPrev->set_sensitive(false);
    
    hboxMain->pack_start(*buttonPrev);
    hboxMain->pack_start(*buttonNext);
    hboxMain->pack_start(*buttonClose);
    
    vboxMain->pack_start(*notebookFind);
    vboxMain->pack_start(*hboxMain, Gtk::PACK_SHRINK, 0);
    
    findBuddyWindow->set_border_width(5);
    findBuddyWindow->set_title("查找/添加");
    findBuddyWindow->property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS);
    findBuddyWindow->set_resizable(true);
    findBuddyWindow->add(*vboxMain);
   
    findBuddyWindow->set_default_size(600,350);

    this->initalize();
    findBuddyWindow->show_all();


    buttonClose->add_accelerator("clicked",
	   gmm_data->getAccelGroup(), GDK_Escape, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);

    buttonPrev->signal_clicked().connect(
	    sigc::mem_fun(*this, &FindBuddyWindow::on_buttonPrev_clicked), false);
    
    buttonNext->signal_clicked().connect(
	    sigc::mem_fun(*this, &FindBuddyWindow::on_buttonNext_clicked), false);
    
    buttonClose->signal_clicked().connect(
		sigc::mem_fun(*this, &FindBuddyWindow::on_buttonClose_clicked), false);
}

FindBuddyWindow::~FindBuddyWindow()
{  
    delete gmm_data;
}

bool FindBuddyWindow::on_delete_event(GdkEventAny*)
{
    GUnit::getMainWindow().on_findBuddyWindow_close(this);
    return true;
}

void FindBuddyWindow::on_buttonClose_clicked()
{
    GUnit::getMainWindow().on_findBuddyWindow_close(this);
}

void FindBuddyWindow::on_buttonPrev_clicked()
{
    int currentPage = notebookFind->get_current_page();
    switch (currentPage) {
	case _HOW_FIND:
	    buttonPrev->set_sensitive(false);
	    notebookFind->set_current_page(_FIND_WHAT);
	    break;
	case _PRECISION_FIND:
	case _ADVANCED_FIND:
	    notebookFind->set_current_page(_HOW_FIND);
	    break;
	case _FIND_CLUSTER:
	    buttonPrev->set_sensitive(false);
	    notebookFind->set_current_page(_FIND_WHAT);
	    break;
	case _FIND_FRIEND_RESULT:
	    buttonNext->set_sensitive(true);
	    notebookFind->set_current_page(currentFind);
	    break;
	case _FIND_CLUSTER_RESULT:
	    buttonNext->set_sensitive(true);
	    notebookFind->set_current_page(_FIND_CLUSTER);
	    break;
	default:
	    fprintf(stderr, "FindBuddyWindow on_buttonPrev_chicked() Error %d\n", currentPage);
	    break;
    }
}

void FindBuddyWindow::on_buttonNext_clicked()
{
    int currentPage = notebookFind->get_current_page();
    switch (currentPage) {
	case _FIND_WHAT:
	    if (radiobuttonFindBuddy->get_active()) {
		notebookFind->set_current_page(_HOW_FIND);
	    } else {
		notebookFind->set_current_page(_FIND_CLUSTER);

	    }
	    buttonPrev->set_sensitive(true);
	    break;
	case _HOW_FIND:
	    if (radiobuttonFindOnline->get_active()) {
		 session->sendPacket(OutPacketPtr(
		                         new SearchUserPacket(*session, 0)));
		 buttonNext->set_sensitive(false);
		 buttonPrev->set_sensitive(false);
		 printf("please wait.......\n");
//		showFriendResultPage(_FIND_ONLINE);
	    } else if (radiobuttonPreciseFind->get_active()) {
		notebookFind->set_current_page(_PRECISION_FIND);
	    } else {
		notebookFind->set_current_page(_ADVANCED_FIND);
	    }
	    break;
	case _PRECISION_FIND:
	    showFriendResultPage(_PRECISION_FIND);
	    break;
	case _ADVANCED_FIND:
	    showFriendResultPage(_ADVANCED_FIND);
	    break;
	case _FIND_CLUSTER:
	    showClusterResultPage();
	    break;
	default:
	    fprintf(stderr, "FindBuddyWindow on_buttonNext_chicked() Error\n");
	    break;
    }
}

void FindBuddyWindow::showFriendResultPage(int findtype)
{
    currentFind = findtype;
    buttonNext->set_sensitive(false);
    notebookFind->set_current_page(_FIND_FRIEND_RESULT);
}

void FindBuddyWindow::showClusterResultPage()
{
    buttonNext->set_sensitive(false);
    notebookFind->set_current_page(_FIND_CLUSTER_RESULT);
}

void FindBuddyWindow::initalize()
{

    Gtk::TreeView::Column* col = Gtk::manage( new Gtk::TreeView::Column("号码") );
    
    col->pack_start(friendResultColumns.Face, false); //false = don't expand.
    col->pack_start(friendResultColumns.Uid, false); //false = don't expand.

    treeviewFriendResult->append_column(*col);
    treeviewFriendResult->append_column("昵称", friendResultColumns.Nickname);
    treeviewFriendResult->append_column("地区", friendResultColumns.Province);

    Gtk::TreeModel::iterator iter = 
	friendResultList->append();

    (*iter)[friendResultColumns.Face] = 
	getPix22(3, QQ_FRIEND_STATUS_ONLINE);
    (*iter)[friendResultColumns.Nickname] = "-------";
    (*iter)[friendResultColumns.Uid]  = "-------";
    (*iter)[friendResultColumns.Province] = "------";


    //....................//


    col = Gtk::manage( new Gtk::TreeView::Column("群号码") );
    
    col->pack_start(clusterResultColumns.Face, false); //false = don't expand.
    col->pack_start(clusterResultColumns.Uid, false); //false = don't expand.
    
    treeviewClusterResult->append_column(*col);
    treeviewClusterResult->append_column("群名称", clusterResultColumns.Nickname);
    treeviewClusterResult->append_column("创建者", clusterResultColumns.Creator);

    iter = clusterResultList->append();

    (*iter)[clusterResultColumns.Face] = 
	getClusterFace22();
    (*iter)[clusterResultColumns.Uid]  = "------";
    (*iter)[clusterResultColumns.Nickname] = "------";
    (*iter)[clusterResultColumns.Creator] = "------";
}
void FindBuddyWindow :: on_RecvResult(QQSession & session)
{
}
